home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 …SCII & the Runetime Code / ADC Developer CD (1992-07) (''Butch ASCII And The Runtime Code'')_iso / Dev.CD 199207.iso / Development Platforms / Apple II / DTS Apple II Sample Code / IR 2.0 / Source Code / IR / IRInit.aii < prev    next >
Encoding:
Text File  |  1992-02-25  |  3.4 KB  |  164 lines  |  [TEXT/MPS ]

  1. *******************************************************************************
  2. * IR -- the Init Restarting init/request proc/Finder Extension/Cheese Slicer
  3. *
  4. * (C)  Copyright Apple Computer, Inc. 1991
  5. * All rights reserved.
  6. *
  7. * by Matt Deatherage
  8. * 10/31/91
  9. *
  10. * This file is the init, called by GS/OS (or IR, in an interesting case of
  11. * circular installation) to install the request proc that is also the Finder
  12. * extension.  Consequently, this file isn't too huge.
  13. *
  14. *
  15. * Modification History:
  16. *
  17. * Version    Author
  18. *
  19. * 2.0a1    Matt Deatherage    11/18/91 (Happy 25th birthday...)
  20. * First version of this file.
  21. *
  22. * 2.0b1    Matt Deatherage    02/18/91
  23. * Now appends the user ID to the request procedure name so more than one
  24. * can exist, at least partially.
  25. *
  26. * 2.0    Matt Deatherage    02/25/92
  27. * Release to the world; no code changes since 2.0b1.
  28. *
  29. *
  30. *******************************************************************************
  31.  
  32.     EJECT
  33. *******************************************************************************
  34. *
  35. IR    PROC
  36. *
  37. * Description:    The init, the entry point.  Our user ID is in the
  38. *    accumulator, and a word of zero is at 4,s -- if we change
  39. *    the low bit of that word to 1, we get unloaded when we're
  40. *    done.
  41. *
  42. *
  43. * Inputs:    None
  44. *
  45. * Outputs:    None
  46. *
  47. * External Refs:
  48.     IMPORT IRRequestProc
  49.     IMPORT IRString
  50.     IMPORT ID1
  51.     IMPORT ID2
  52.     INCLUDE 'E16.IR'
  53.     INCLUDE 'M16.Memory'
  54.     INCLUDE 'M16.Util2'
  55.     INCLUDE 'M16.Locator'
  56.     INCLUDE 'E16.Locator'
  57.     INCLUDE 'M16.MiscTool'
  58.     INCLUDE 'M16.Loader'
  59.     INCLUDE 'M16.IntMath'
  60.     INCLUDE 'M16.QuickDraw'
  61. *
  62. * Entry Points:
  63. *
  64. *******************************************************************************
  65.  
  66.     phb
  67.     phk
  68.     plb
  69.     
  70. ;
  71. ; First, see if we have QuickDraw version 3.7 or greater to indicate 6.0 or later.
  72. ;
  73.  
  74.     pha    ; space for result
  75.     _QDVersion
  76.     pla
  77.     and #$0FFF    ; clear off prototype/other bits (IIgs TN #100)
  78.     cmp #$0307
  79.     bge InstallIR
  80.     brl badIRenv    ; bad environment
  81.     
  82. ;
  83. ; If we have it, install the request proc
  84. ;
  85.  
  86. InstallIR    pha
  87.     _MMStartUp
  88.     pla    ; for bug in old IR application
  89.     sta initID    ; keep a copy of the user ID
  90.  
  91. ;
  92. ; The old IR application had a bug in some versions where it didn't necessarily
  93. ; have the user ID in A before dispatching to an init.  So, to be defensive
  94. ; against my own mistakes, I put the above check in.  -MD
  95. ;
  96.  
  97. ;
  98. ; Now, append our user ID in hex form to the string so we can keep more than
  99. ; one around for a brief time if necessary.
  100. ;
  101.  
  102.     pha
  103.     pha
  104.     pha    ; ID still in A
  105.     _Hexit
  106.     
  107.     pla
  108.     sta ID1
  109.     pla
  110.     sta ID2    ; store inside the string
  111.     
  112.  
  113.     pushlong #IRString
  114.     pushword initID    ; now we need this
  115.     pushlong #IRRequestProc
  116.     _AcceptRequests
  117.     bcs badIRenv    ; can't install IR
  118.     
  119. ;
  120. ; Got it in, so let's send it the startup request.  We need a pointer to the user ID.
  121.     
  122.     pushword #askIRStartUp
  123.     pushword #sendToName
  124.     pushlong #IRString    ; the target
  125.     pushlong #initID    ; address of the user ID
  126.     lda #0
  127.     pha
  128.     pha    ; dataOut == NIL to prevent Tool Locator from using it
  129.     _SendRequest
  130.     bcs badIRenv    ; can't start it up
  131.     
  132. ;
  133. ; We're done!
  134. ;
  135.     plb
  136.     rtl    ; we're done
  137.     
  138. ;
  139. ; Here's the place we go when we can't install.
  140. ;
  141.  
  142. badIRenv    plb
  143.     lda 4,s
  144.     bne @rtl    ; don't change word if not zero!
  145.     ora #$0001
  146.     sta 4,s    ; tell GS/OS to shut us down
  147. @rtl    rtl
  148.  
  149. ;
  150. ; Static data for the init
  151. ;
  152.  
  153. InitID    ds.w 1    ; copy of user ID
  154. dataOutStorage    ds.w 1    ; recvCount
  155. BootIcon    ds.l 1    ; icon pointer
  156. BootString    ds.l 1    ; string pointer
  157.  
  158. srqGoAwayBuffer    dc.w 0    ; recvCount
  159. srqUserID    dc.w 0    ; user ID
  160. srqShutdownFlag    dc.w 0    ; shutdown flag
  161.  
  162.     EndP
  163.     END